package com.sina.auto.components.AddContentImpl;

import com.sina.auto.components.AddContentInterface.AddContent;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;

import static com.sina.auto.components.AddContentImpl.ImageUtil.MergeImage.mergeImage;

public class ImageOutput implements AddContent {

    @Override
    public BufferedImage imageoutput(String Content) throws Exception {

        BufferedImage t3 = ImageIO.read(new File("template/template3.jpg"));
        BufferedImage img1 = ImageIO.read(new FileInputStream("template/template1.jpg"));
        BufferedImage img2 = AddString.addString(t3, Content);
        BufferedImage img3 = ImageIO.read(new FileInputStream("template/template2.jpg"));
        BufferedImage[] images = {img1, img2, img3};

        return (mergeImage(images, 2));
    }

    @Override
    public BufferedImage imageoutputonlyTitle(String Content, String title) throws Exception {
        BufferedImage t3 = ImageIO.read(new File("template/template3.jpg"));
        BufferedImage img1 = ImageIO.read(new FileInputStream("template/template1.jpg"));
        BufferedImage img2 = AddString.addStringOnlyTitle(t3, Content, title);
        BufferedImage img3 = ImageIO.read(new FileInputStream("template/template2.jpg"));
        BufferedImage[] images = {img1, img2, img3};

        return (mergeImage(images, 2));
    }

    @Override
    public BufferedImage imageoutput(String Content, String author, String title) throws Exception {

            BufferedImage t3 = ImageIO.read(new File("template/template3.jpg"));
            BufferedImage img1 = ImageIO.read(new FileInputStream("template/template1.jpg"));
            BufferedImage img2 = AddString.addString(t3, Content, author, title);
            BufferedImage img3 = ImageIO.read(new FileInputStream("template/template2.jpg"));
            BufferedImage[] images = {img1, img2, img3};

            return (mergeImage(images, 2));
        }

    @Override
    public BufferedImage imageoutputonlyAuthor(String Content, String author) throws Exception {

        BufferedImage t3 = ImageIO.read(new File("template/template3.jpg"));
        BufferedImage img1 = ImageIO.read(new FileInputStream("template/template1.jpg"));
        BufferedImage img2 = AddString.addStringOnlyAuthor(t3, Content, author);
        BufferedImage img3 = ImageIO.read(new FileInputStream("template/template2.jpg"));
        BufferedImage[] images = {img1, img2, img3};

        return (mergeImage(images, 2));
    }

    @Override
    public BufferedImage imageoutputParagraph(String[] Content) throws Exception {
        BufferedImage t3 = ImageIO.read(new File("template/template3.jpg"));
        BufferedImage img1 = ImageIO.read(new FileInputStream("template/template1.jpg"));
        BufferedImage img2 = AddString.addString(t3, Content);
        BufferedImage img3 = ImageIO.read(new FileInputStream("template/template2.jpg"));
        BufferedImage[] images = {img1, img2, img3};

        return (mergeImage(images, 2));
    }

}

